Page({
  data:{
    phone_number:'',
    passwd:'',
    isPassword:true,
    isDeletePhone:false,
    isDeletePasswd:false,
  },

  onLoad(){

  },

  phoneInput(e){
    const phone_number = e.detail.value;
    this.setData({
      phone_number:phone_number,
      isDeletePhone:true
    });
  },

  passwdInput(e){
    const passwd = e.detail.value;
    this.setData({
      passwd:passwd,
      isDeletePasswd:true
    });
  },

  //清空手机号信息
  clearPhoneInput(){
    this.setData({
      phone_number:''
    })
  },
  
  //清空密码信息
  clearPasswdInput(){
    this.setData({
      passwd:''
    })
  },

  //显示密码
  showPasswd(){
    this.setData({
      isPassword:false
    })
  },

  //影藏密码
  hiddenPasswd(){
    this.setData({
      isPassword:true
    })
  },
  
  //手机号输入框焦点
  phoneInputFocus(){
    this.setData({
      isDeletePhone:!this.data.isDeletePhone
    })
  },
  
  //密码输入框焦点
  passwdInputFocus(){
    this.setData({
      isDeletePasswd:!this.data.isDeletePasswd
    })
  },

  //病人注册
  registerPatients(e){
    const patientsInfo = e.detail.value;
    console.log(patientsInfo);
    const phone_number = Number(patientsInfo.phone_number);
    const passwd = patientsInfo.passwd;
    if(phone_number === 0 || passwd === ''){
      wx.showToast({
        title: '请填写完整',
        icon:'error'
      })
    }else if(phone_number.toString().length !== 11 || typeof(phone_number) !== 'number'){
       wx.showToast({
         title: '非法手机号',
         icon:'error'
       }) 
    }else{
      wx.showToast({
        title: '注册成功',
        icon:'success'
      })
    }
  },
  
})